﻿using PLCS.Application.Contracts.HisTaskApp.Dtos;
using PLCS.Application.Contracts.InterfaceApp.Dtos;
using PLCS.Client.IService.LogManager;
using System.Collections.ObjectModel;
using Volo.Abp.Application.Dtos;

namespace PLCS.Client.Service.LogManager;

public class InterfaceLogService : BaseService<InterfaceLogDto, InterfaceLogDto>, IInterfaceLogService
{
    public async Task<PagedResultDto<InterfaceLogDto>> GetListBySearchAsync(int skipCount, int maxResultCount, string? startTime, string? endTime, string? requestSide, string? responseSide)
    {
        var route = $"interfaceLog/bySearch?SkipCount={skipCount}&MaxResultCount={maxResultCount}";
        if (!string.IsNullOrEmpty(startTime))
            route += $"&startTime={startTime}";
        if (!string.IsNullOrEmpty(endTime))
            route += $"&endTime={endTime}";
        if (!string.IsNullOrEmpty(requestSide))
            route += $"&requestSide={requestSide}";
        if (!string.IsNullOrEmpty(responseSide))
            route += $"&responseSide={responseSide}";
        RequestParam requestParam = new(method: Method.Get, route: route);
        var apiRes = await restClient.ExecuteAsync<PagedResultDto<InterfaceLogDto>>(requestParam);
        if (apiRes.Status)
            return apiRes.Data;
        else
            return new PagedResultDto<InterfaceLogDto>();
    }
}